import json

import requests

# url = "https://httpbin.org/get"
# # 发起请求 获取响应
# res = requests.get(url)
# # 直接将响应结果转换为json对象
# data = res.json()
# print(type(data),data['headers']['User-Agent'])


url = "https://www.baidu.com/robots.txt"
res = requests.get(url)
print(res.text)

# url = "http://htpptbin.org/get"
# res = requests.get(url)
# print(res.text)
# data = json.loads(res.text)
# print(type(data),data['headers']['User-Agent'])

# # content 手动解码
# url = "http://www.baidu.com"
# res = requests.get(url)
# # 手动解码
# data = res.content.decode()
# print(type(data),data)

# url = "http://httpbin.org/get"
# res = requests.get(url)
# data = json.loads(res.content.decode())
# print(data['headers']['User-Agent'])

# url = "https://img1.baidu.com/it/u=3518673092,2032183538&fm=253&fmt=auto&app=138&f=JPEG"
# res = requests.get(url)
# with open("text.jpeg",mode="wb") as f:
#     f.write(res.content)































